package com.itheima.app.controller;

import com.itheima.app.manager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {

    @Autowired
    private SettingManager settingManager;

    // 查询通用设置
    @GetMapping("/users/settings")
    public ResponseEntity findSetting() {
        return settingManager.findSetting();
    }

    // 设置陌生人问题
    @PostMapping("/users/questions")
    public ResponseEntity setQuestion(@RequestBody Map<String, String> map) {
        // 1.接收参数
        String content = map.get("content");

        // 2.调用manager
        return settingManager.setQuestion(content);
    }

    // 设置推送通知
    @PostMapping("/users/notifications/setting")
    public ResponseEntity setNotification(@RequestBody Notification notificationParam){
        // 调用manager
        return settingManager.setNotification(notificationParam);
    }

    // 分页查询黑名单
    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "8") Integer pageSize){
        return settingManager.findBlackListByPage(pageNum,pageSize);
    }

    // 黑名单移出
    @DeleteMapping("/users/blacklist/{uid}")
    public ResponseEntity deleteBlackList(@PathVariable("uid") Long blackId){
        return settingManager.deleteBlackList(blackId);
    }
}
